var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}), (o.QiriHongbao = void 0);
var a = t("Counter"),
    i = t("Platforms"),
    s = t("Popup"),
    c = t("Sounds"),
    l = t("TableRules"),
    u = t("QiriHongbaoItem"),
    p = t("ConfS"),
    f = cc._decorator,
    d = f.ccclass,
    h =
        (f.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            var o;
            return (
                n(e, t),
                (o = e),
                (e.prototype.init = function () {
                    var t = this;
                    if (p.DatasManager.红包) {
                        (this.time = this.node.getChildByName("time").getComponent(cc.Label)),
                            (this.day = this.node.getChildByName("day").getComponent(cc.Label));
                        var e,
                            n = new Date();
                        i.default.userStorage.七日红包开始领的时间 > 0
                            ? (e = new Date(i.default.userStorage.七日红包开始领的时间))
                            : ((e = new Date(n.getFullYear(), n.getMonth(), n.getDate())),
                              (i.default.userStorage.七日红包开始领的时间 = e.getTime()),
                              i.default.userStorage.setDirty()),
                            (o.startSec = Math.ceil(i.default.userStorage.七日红包开始领的时间 / 1e3));
                        var r = Math.ceil(n.getTime() / 1e3);
                        if (!(r < o.startSec)) {
                            var s = o.startSec + 86400 * p.DatasManager.七日红包持续天数 - r;
                            if ((console.log("七日红包", s, e, n), s < 0)) console.log(p.DatasManager.七日红包已结束);
                            else {
                                (this.counter = new a.default()),
                                    this.counter.init(s, function (e) {
                                        t.time.string = i.default.formatTime(e, !0, !0);
                                    }),
                                    this.counter.start(function () {
                                        (t.counter = null), t.hide();
                                    }),
                                    (o.第n天 = Math.ceil((r - o.startSec) / 86400)),
                                    (this.day.string = "第" + o.第n天 + "天");
                                var l = this.node.getChildByName("hongbaos");
                                this.items = new Array();
                                for (var f = 0; f < 4; f++) {
                                    var d = i.default.prefabs
                                        .instantiate("七日红包Item")
                                        .getComponent(u.QiriHongbaoItem);
                                    l.addChild(d.node), (d.node.x = 170 * f), this.items.push(d), d.init(f);
                                }
                                (this.close = this.node.getChildByName("close")),
                                    this.close.on(cc.Node.EventType.TOUCH_END, function () {
                                        c.Sounds.playFX("点击"), t.hide();
                                    }),
                                    this.refresh();
                            }
                        }
                    }
                }),
                (e.prototype.refresh = function () {
                    if (this.items)
                        for (var t = 0, e = this.items; t < e.length; t++) {
                            e[t].refresh();
                        }
                }),
                (e.prototype.show = function () {
                    t.prototype.show.call(this), l.TableRules.pause();
                }),
                (e.prototype.showComplete = function () {
                    t.prototype.showComplete.call(this);
                }),
                (e.prototype.hide = function () {
                    t.prototype.hide.call(this);
                }),
                (e.prototype.hideComplete = function () {
                    if ((t.prototype.hideComplete.call(this), l.TableRules.resume(), this.onHide)) {
                        var e = this.onHide;
                        (this.onHide = null), e();
                    }
                }),
                (e = o = r([d], e))
            );
        })(s.Popup));
o.QiriHongbao = h;
